/*
 * Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
 * 
 * This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
 * printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
 * without the written permission of iTAC Software AG.
 */
package org.template.portal;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

// TODO
/**
 * @author rafal.kojta
 */
@Entity
@Table(name = "directory")
public class Directory {
  @Id
  @GeneratedValue(strategy = IDENTITY)
  @Column(name = "DIRECTORY_ID", unique = true, nullable = false)
  private long directoryId;

  @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
  @JoinColumn(name = "ROOT_DIRECTORY_ID")
  private RootDirectory rootDirectory;// parent

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "rootDirectory")
  private Set<Directory> directories = new HashSet<Directory>();// children

  @Column(name = "NAME")
  private String name;

  @Column(name = "IS_ROOT")
  private boolean isRoot;

  public Directory() {

  }

  public long getDirectoryId() {
    return directoryId;
  }

  public void setDirectoryId(long directoryId) {
    this.directoryId = directoryId;
  }

  public Set<Directory> getDirectories() {
    return directories;
  }

  public void setDirectories(Set<Directory> directories) {
    this.directories = directories;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public boolean isRoot() {
    return isRoot;
  }

  public void setRoot(boolean isRoot) {
    this.isRoot = isRoot;
  }

}
